package com.roncoo.order.controller;


import com.roncoo.order.entity.EduCourse;
import com.roncoo.order.service.EduCourseService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * (EduCourse)表控制层
 *
 * @author makejava
 * @since 2021-03-26 09:24:48
 */
@RestController
@Api(tags = "(EduCourse)")
@RequestMapping("eduCourse")
public class EduCourseController {
    /**
     * 服务对象
     */
    @Resource
    private EduCourseService eduCourseService;

    /**
     * 查询课程信息
     */
    @PostMapping("getOneCourse")
    public EduCourse getData(EduCourse eduCourse){
        return eduCourseService.getData(eduCourse);
    }




    /**
     * 分页查询所有数据
     *
     * @param page 分页对象
     * @return 所有数据
     */
    @ApiOperation(value = "分页查询")
    @GetMapping
    public Page<EduCourse> selectAll(Page<EduCourse> page) {
        return null;
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询 ")
    @GetMapping("selectOne/{id}")
    public EduCourse selectOne(@ApiParam(value = " ID") @PathVariable("id") Integer id) {
        return this.eduCourseService.getById(id);
    }

    /**
     * 新增数据
     *
     * @param eduCourse 实体对象
     * @return 新增结果
     */
    @PostMapping
    public boolean insert(@RequestBody EduCourse eduCourse) {
        return this.eduCourseService.save(eduCourse);
    }

    /**
     * 修改数据
     *
     * @param eduCourse 实体对象
     * @return 修改结果
     */
    @PutMapping
    public boolean update(@RequestBody EduCourse eduCourse) {
        return this.eduCourseService.updateById(eduCourse);
    }

    /**
     * 删除数据
     *
     * @param id 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    public boolean delete(Long id) {
        return this.eduCourseService.removeById(id);
    }
}
